package com.lmc.health;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;

import com.lmc.R;
import com.lmc.adapter.HealthReportAdapter;
import com.lmc.entity.Health;
import com.lmc.util.DateFormatUtil;
import com.qxzn.app.page.BaseActivity;

/**
 * 每日健康报告
 */
public class HealthReportActivity extends BaseActivity {


    private TextView name;
    private TextView time;
    private ListView listView;
    private Health health;

    @Override
    protected int initLayout() {
        return R.layout.activity_health_report;
    }

    @Override
    protected void initView() {

        name = (TextView) findViewById(R.id.name);
        time = (TextView) findViewById(R.id.time);
        listView = (ListView) findViewById(R.id.listView);
    }

    @Override
    protected void iniTitleBar() {
        tv_title.setText("每日报告");
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        health = (Health) getIntent().getSerializableExtra("health");
        name.setText(health.getData().getNiname() + "/" + health.getData().getAge() + "岁");
        time.setText(DateFormatUtil.forString(health.getData().getResult().get(0).getDate(),"yyyy.MM.dd"));

        listView.setAdapter(new HealthReportAdapter(this, health.getData().getResult()));

    }


    public static void start(Context context, Health health) {
        Intent intent = new Intent(context, HealthReportActivity.class);
        intent.putExtra("health", health);
        context.startActivity(intent);
    }
}
